<template>
  <div class="wrapper">
    <!-- <vetical-menu :routers="routers"></vetical-menu> -->
    <el-menu
      router
      :default-active="$route.path"
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">
      <el-submenu v-for="router in routers" :key="router.path" :index="router.path" :route="{path: router.path}" :router="router">
        <template v-slot:title>
          {{router.meta.name}}
        </template>
        <el-menu-item-group>
          <el-menu-item v-for="router in routers" :key="router.path" :index="router.path" :route="{path: router.path}" :router="router">
            {{router.meta.name}}
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
    <router-view class="router-view" />
  </div>
</template>

<script>
  // import veticalMenu from '@/components/menu';

  export default {
    data() {
      return {
        routers: []
      }
    },
    mounted() {
      this.routers = JSON.parse(sessionStorage.getItem('authorization'));
      this.routers[0].children = [{
        path: '/abc1',
        name: 'abc',
        meta: {
          name: '首页子项1',
          activeMenu: '/admin1'
        },
        component: 'admin1'
      }, {
        path: '/abc2',
        name: 'abc',
        meta: {
          name: '首页子项2',
          activeMenu: '/admin2'
        },
        component: 'admin2'
      }]
    }
  }
</script>

<style lang="scss">
  .wrapper {
    height: 100%;
    display: flex;

    .el-menu-vertical-demo {
      width: 200px;
      height: 100%;
    }

    .router-view {
      flex: 1;
    }
  }
</style>
